//
//  FulisheJifenListCell.m
//  ToListenPhone
//
//  Created by zhibao on 2023/7/20.
//

#import "FulisheJifenListCell.h"

@interface FulisheJifenListCell(){
    UILabel *nameLabel;
    UILabel *detailLabel;
    UILabel *jifenLabel;
}
@end

@implementation FulisheJifenListCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        nameLabel = [[UILabel alloc]init];
        nameLabel.font = MY_SCALE_RegularFONT(13);
        nameLabel.textColor = MYBlock;
        [self.contentView addSubview:nameLabel];
        [nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.top.mas_equalTo(20);
        }];
        
        detailLabel = [[UILabel alloc]init];
        detailLabel.font = MY_SCALE_RegularFONT(11);
        detailLabel.textColor = MyColor(@"999999");
        [self.contentView addSubview:detailLabel];
        [detailLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(nameLabel);
            make.top.equalTo(nameLabel.mas_bottom).offset(6);
            make.bottom.equalTo(self.contentView).offset(-20);
        }];
        
        jifenLabel = [[UILabel alloc]init];
        jifenLabel.font = MY_SCALE_RegularFONT(15);
        jifenLabel.textColor = MyColor(@"#E76C3C");
        [self.contentView addSubview:jifenLabel];
        [jifenLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.equalTo(self.contentView).offset(-20);
            make.centerY.equalTo(self.contentView);
        }];
        
        UIView *line = [UIView new];
        line.backgroundColor = MyColor(@"#F3F3F3");
        [self.contentView addSubview:line];
        [line mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(20);
            make.right.mas_equalTo(-20);
            make.height.mas_equalTo(0.5);
            make.bottom.equalTo(self.contentView);
        }];
    }
    return self;
}

- (void)update:(NSDictionary *)dic{
    int state = [dic[@"state"] intValue];
    int type = [dic[@"type"] intValue];
    if(type == 0){
        nameLabel.text = @"兑换邀请码";
    }else if(type == 1){
        nameLabel.text = @"积分签到";
    }else if(type == 2){
        nameLabel.text = @"兑换商品";
    }else if(type == 3){
        nameLabel.text = @"过期";
    }
    
    if(state == 0){
        jifenLabel.textColor = MyColor(@"#E76C3C");
        detailLabel.text = [NSString stringWithFormat:@"增加 %@",dic[@"create_date"]];
    }else{
        jifenLabel.textColor = MyColor(@"#50BF9D");
        detailLabel.text = [NSString stringWithFormat:@"减少 %@",dic[@"create_date"]];
    }
    jifenLabel.text = dic[@"value"];
}
- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
